import cv2
import numpy as np

img=np.zeros((150,400,3),np.uint8)

def doChange(param):
    b=cv2.getTrackbarPos('B', 'tracebar')
    g = cv2.getTrackbarPos('G', 'tracebar')
    r = cv2.getTrackbarPos('R', 'tracebar')
    img[:] = [b, g, r]
cv2.namedWindow('tracebar')
cv2.createTrackbar('B', 'tracebar', 0, 255, doChange)
cv2.createTrackbar('G', 'tracebar', 0, 255, doChange)
cv2.createTrackbar('R', 'tracebar', 0, 255, doChange)

while True:
    cv2.imshow('tracebar',img)
    if cv2.waitKey(1) == ord('q'):
        break
cv2.destroyAllWindows()
